<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzb.erp.api.pc.shop.mapper.OrderRefundMapper">

    <select id="getList" resultType="com.hzb.erp.api.pc.shop.pojo.OrderRefundVo">
        select
            t1.id,t1.refund_sn,t1.refund_money,t1.item_names,t1.verify_time,t1.verify_remark,
            t1.wx_refund_id,t1.add_time,t1.reason,t1.state,t1.operator_name,t1.operation_time,
            t3.sn order_sn,
            t2.name student_name,
            t6.mobile,
            t3.sn order_sn,
            t4.name verify_name,
            t5.name reason_type_text
        from shop_order_refund t1
        left join shop_order t3 on t3.id = t1.order_id
        left join student t2 on t2.id = t1.student_id
        left join staff t4 on t4.id = t1.verify_staff
        left join dict_item t5 on t5.id = t1.reason_type
        left join `user` t6 on t6.id = t1.user_id
        <where>
            <if test="param.orderId != null">
                AND t1.order_id = #{param.orderId}
            </if>
            <if test="param.studentId != null">
                AND t1.student_id = #{param.studentId}
            </if>
            <if test="param.orderSn != null and param.orderSn.trim() != ''">
                AND t3.sn like concat( #{param.orderSn}, '%')
            </if>
            <if test="param.state != null and param.state.size()>0">
                AND t1.state in
                <foreach collection="param.state" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="param.refundSn != null and param.refundSn.trim() != ''">
                AND t1.refund_sn like concat( #{param.refundSn}, '%')
            </if>
            <if test="param.reasonType != null">
                AND t5.id = #{param.reasonType}
            </if>
            <if test="param.startDate != null and param.endDate != null">
                AND ( t1.add_time &gt;= #{param.startDate} and t1.add_time &lt;= #{param.endDate} )
            </if>
        </where>
        order by t1.id desc
    </select>
</mapper>
